home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / The Hacks! / COSEmulator / COSEmulator- SRC / src / Window.cpp < prev    next >
Encoding:
Text File  |  1998-06-21  |  4.9 KB  |  212 lines  |  [TEXT/CWIE]

  1. //===================================================================
  2. //=======================  Headers        =============================
  3.  
  4. #include "Window.h"
  5. #include "GameUtilities.h"
  6. #include "Screen.h"
  7.  
  8. //===================================================================
  9. //=======================  Globals        =============================
  10.  
  11.  
  12. //===================================================================
  13. //=======================  #define        =============================
  14.  
  15.  
  16. //===================================================================
  17. //=======================  Function Prototypes    =====================
  18.  
  19.  
  20. /*----------------------------------------------------------------------------\
  21.  
  22.     Window :: Constructor
  23.  
  24. \----------------------------------------------------------------------------*/
  25.     Window :: Window( void )
  26. {
  27.     front = true;
  28.     draging = false;
  29.     
  30.     width = 0;
  31.     height = 0;
  32.     
  33.     shaded = false;
  34.     hiden = true;
  35.     
  36.     dragable = false;
  37. }
  38.  
  39. /*----------------------------------------------------------------------------\
  40.  
  41.     Window :: Destructor
  42.  
  43. \----------------------------------------------------------------------------*/
  44.     Window :: ~Window( void )
  45. {
  46.     
  47. }
  48.  
  49. /*----------------------------------------------------------------------------\
  50.  
  51.     Window :: Init
  52.  
  53. \----------------------------------------------------------------------------*/
  54. Boolean    Window :: Init( void )
  55. {
  56.     if( window.LoadPicBuff( 128 ) )
  57.     {
  58.         screenLoc.left = 0;
  59.         screenLoc.top = 20;
  60.         width = window.GetBoundsSize().right;
  61.         height = window.GetBoundsSize().bottom;
  62.         screenLoc.right = screenLoc.left + width;
  63.         screenLoc.bottom = screenLoc.top + height;
  64.         
  65.         return true;
  66.     }
  67.     
  68.     return false;
  69. }
  70.  
  71. /*----------------------------------------------------------------------------\
  72.  
  73.     Window :: HandleMouseClick
  74.  
  75. \----------------------------------------------------------------------------*/
  76. void    Window :: HandleMouseClick( Boolean down , point where )
  77. {
  78.     if( down )
  79.     {
  80.         draging = true;
  81.         start = where;
  82.     }
  83.     else
  84.     {
  85.         if( draging )
  86.         {
  87.             screen.AddRectToUpdate( screenLoc );
  88.             
  89.             MyOffSetRect( &screenLoc , where.x - start.x , where.y - start.y );
  90.  
  91.             screen.AddRectToUpdate( screenLoc );
  92.             
  93.             draging = false;
  94.         }
  95.     }
  96. }
  97.  
  98. /*----------------------------------------------------------------------------\
  99.  
  100.     Window :: HandleMouseMove
  101.  
  102. \----------------------------------------------------------------------------*/
  103. void    Window :: HandleMouseMove( point where )
  104. {
  105.     if( draging )
  106.     {
  107.         screen.AddRectToUpdate( screenLoc );
  108.         
  109.         MyOffSetRect( &screenLoc , where.x - start.x , where.y - start.y );
  110.         start = where;
  111.         
  112.         screen.AddRectToUpdate( screenLoc );
  113.     }
  114. }
  115.  
  116. /*----------------------------------------------------------------------------\
  117.  
  118.     Window :: PointInWindow
  119.  
  120. - just saids if the point it inside the window area or not
  121. \----------------------------------------------------------------------------*/
  122. Boolean    Window :: PointInWindow( point where )
  123. {
  124.     return SectPtRect( where , screenLoc );
  125. }
  126.  
  127. /*----------------------------------------------------------------------------\
  128.  
  129.     Window :: Active
  130.  
  131. \----------------------------------------------------------------------------*/
  132. Boolean    Window :: Front( void )
  133. {
  134.     return( front );
  135. }
  136.  
  137. /*----------------------------------------------------------------------------\
  138.  
  139.     Window :: SetFront
  140.  
  141. \----------------------------------------------------------------------------*/
  142. void    Window :: SetFront( Boolean f )
  143. {
  144.     if( f != front )
  145.     {
  146.         front = f;
  147.         screen.AddRectToUpdate( screenLoc );
  148.     }
  149. }
  150.  
  151. /*----------------------------------------------------------------------------\
  152.  
  153.     Window :: DrawToScreen
  154.  
  155. \----------------------------------------------------------------------------*/
  156. void    Window :: DrawToScreen( rect *where , Boolean backGround )
  157. {
  158.     if( front && !backGround )
  159.     {
  160.         if( where == NULL )
  161.         {
  162.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  163.                         NULL , 0 , 0 , 0 );
  164.         }
  165.         else
  166.         {
  167.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  168.                         where , 0 , 0 , 0 );
  169.         }
  170.     }
  171.     else
  172.     {
  173.         if( where == NULL )
  174.         {
  175.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  176.                         NULL , kDrawTint , 16 , 0xffff );
  177.         }
  178.         else
  179.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  180.                         where , kDrawTint , 16 , 0xffff );
  181.     }
  182. }
  183.  
  184. /*----------------------------------------------------------------------------\
  185.  
  186.     Window :: HideWindow
  187.  
  188. \----------------------------------------------------------------------------*/
  189. void    Window :: HideWindow( Boolean h )
  190. {
  191.     
  192. }
  193.  
  194. /*----------------------------------------------------------------------------\
  195.  
  196.     Window :: ShadeWindow
  197.  
  198. \----------------------------------------------------------------------------*/
  199. void    Window :: ShadeWindow( Boolean s )
  200. {
  201.     
  202. }
  203.  
  204. /*----------------------------------------------------------------------------\
  205.  
  206.     Window :: AddToUpdate
  207.  
  208. \----------------------------------------------------------------------------*/
  209. void    Window :: AddToUpdate( void )
  210. {
  211.     screen.AddRectToUpdate( screenLoc );
  212. }